Developer --> Technical Publications
PATHMac OS 8 Developer Documentation > Files > Navigation Services >

Programming With Navigation Services 1.1


Handling Events

To respond to events generated by the user and Navigation Services, you can create an event-handling function, described in this document as MyEventProc . You register your event-handling function by passing a Universal Procedure Pointer (UPP) in the eventProc parameter of a Navigation Services function such as NavGetFile . You obtain this UPP by calling the macro NewNavEventProc and passing a pointer to your event-handling function. If an event occurs while the Open dialog box is displayed, for example, the NavGetFile function will call your event-handling function. In the callBackParms parameter of your event-handling function, NavGetFile supplies a structure of type NavCBRec . This structure contains the information your application needs to respond to the event. For instance, your application can obtain the event record describing the event to be handled from the pointer in the event field of the NavCBRec structure.

Navigation Services will pass update events that apply only to your windows. When calling your event-handling function, Navigation Services passes mouse-down events only when they occur in the preview or customization areas.

You are strongly encouraged to provide at least a simple function to handle update events. If you do this, Navigation Services dialog boxes automatically become movable and resizable. Listing 6 shows an example of such a function.

Listing 6 A sample event-handling function

pascal void myEventProc(NavEventCallbackMessage callBackSelector,
                        NavCBRecPtr callBackParms,
                        NavCallBackUserData callBackUD)
{
    WindowPtr window =
                    (WindowPtr)callBackParms->eventData.event->message;
    switch (callBackSelector)
    {
        case kNavCBEvent:
            switch (callBackParms->eventData.event->what)
            {
                case updateEvt:
                    MyHandleUpdateEvent(window,
                        (EventRecord*)callBackParms->eventData.event);
                    break;
            }
            break;
    }
}

In your event-handling function, you can also call the function NavCustomControl to control various aspects of dialog boxes. For example, the following line shows how you can determine whether the preview area is currently showing:

NavCustomControl(context, kNavCtlIsPreviewShowing, &isShowing);

If you extend the type pop-up menus with custom menu items, Navigation Services expects your event-handling function to respond to these items. For more information, see Customizing Type Pop-up Menus.


© 1998 Apple Computer, Inc. – (Last Updated 23 Nov 98)

Previous | Back Up One Level | Next |